package com.example.dense_rack_server.utils;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.dense_rack_server.entity.Host;
import com.example.dense_rack_server.service.ArchivesService;
import com.example.dense_rack_server.service.HostService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * 服务器启动成功后修改连接状态
 */
@Slf4j
@Component
public class UpdateCabinetConnectionStatus {

    @Resource
    private HostService hostService;


    @PostConstruct
    public void connectionStatus() {
        // 在这里编写你的启动后需要执行的代码
        boolean success = hostService.update(new UpdateWrapper<Host>().set("online_status", 0));
        if (success) {
            log.info("修改连接状态成功");
        }else {
            log.error("修改连接状态失败");
        }
    }
}
